# coding:utf-8
from odoo import models, fields, api, _
import odoo.addons.decimal_precision as dp


class OLProductTemplate(models.Model):
    _name = 'product.template'
    _inherit = 'product.template'

    list_price = fields.Float(
        'Sale Price', default=0.0,
        digits=dp.get_precision('Product Price'),
        help="Base price to compute the customer price. Sometimes called the catalog price.")

    permissible_proportion = fields.Float(u'允出比例%', default=0, required=True, digits=0)
    permissible_proportion_manager = fields.Boolean(u'管理允出比例', default=False)
    user_id = fields.Many2one('res.users', string=u'业务员')
    team_id = fields.Many2one('crm.team', string=u'销售团队')
    enable_minimum_sales_qty = fields.Boolean(string=u'启用最小起订量')
    minimum_sales_qty = fields.Float(string=u'最小起订量', copy=False, required=True,
                                     digits=dp.get_precision('Product Unit of Measure'), default=0.0)
    qc_flag = fields.Boolean(string=u'是否质检')

    @api.onchange('permissible_proportion_manager')
    def onchange_proportion(self):
        if not self.permissible_proportion_manager:
            self.permissible_proportion = 0
